package com.ebo.httpcall4j.core.retry;

import lombok.Builder;
import lombok.Data;

/**
 * 重试策略
 */
@Data
@Builder
public class RetryStrategy {

    /**
     * 最大重试次数
     */
    @Builder.Default
    private int maxRetries = 3;

    /**
     * 初始重试间隔时间（毫秒）
     */
    @Builder.Default
    private long retryDelayMillis = 1000;

    /**
     * 重试间隔的退避乘数
     */
    @Builder.Default
    private double backoffMultiplier = 1.0;

    public RetryStrategy() {
    }

    public RetryStrategy(int maxRetries, long retryDelayMillis, double backoffMultiplier) {
        this.maxRetries = maxRetries;
        this.retryDelayMillis = retryDelayMillis;
        this.backoffMultiplier = backoffMultiplier;
    }

    /**
     * 默认的重试策略
     */
    public static RetryStrategy defaultStrategy() {
        return RetryStrategy.builder().build();
    }
}